Skip to content

89 validate writer exclusivity for link from at config time#90

Merged
lxsaah merged 3 commits intomainfrom
89-validate-writer-exclusivity-for-link_from-at-config-time
May 8, 2026
Merged

89 validate writer exclusivity for link from at config time#90
lxsaah merged 3 commits intomainfrom
89-validate-writer-exclusivity-for-link_from-at-config-time

Conversation

@lxsaah
Copy link
Copy Markdown
Contributor

@lxsaah lxsaah commented May 8, 2026

Closes #89.

Summary

  • Writer-exclusivity for .link_from() enforced at config time. .source(), .transform(), and .link_from() all push into the same buffer; combining any two on a single record was previously accepted and silently degraded to last-writer-wins on latest_snapshot. The configuration now panics with a clear message instead. Extends the existing .source().transform() check (aimdb-core/src/typed_record.rs:638,726) to cover the inbound side, closing the gap called out in the issue.
  • Symmetric checks across all three setters. set_producer_service and set_transform panic if inbound_connectors is non-empty; add_inbound_connector panics if a source or transform is registered. Same cfg(feature = "std") lock pattern as the existing checks.
  • Builder-level pre-check with URL context. LinkFromBuilder::finish() runs the same check via the existing has_transform() / has_producer_service() accessors before calling add_inbound_connector, so the panic message includes the offending URL (e.g. Record already has a .source(); cannot also have a .link_from() for mqtt://broker/topic). The record-level check remains the source of truth.
  • Multiple .link_from() on the same record stays allowed. Fan-in (redundant brokers, multi-source ingestion) is a legitimate pattern; only mixing inbound with local writers is rejected.

Tests

Added 5 tests in aimdb-core/src/typed_api.rs:

  • link_from_after_source_panics, link_from_after_transform_panics — exercise the URL-bearing panic from LinkFromBuilder::finish().
  • source_after_link_from_panics, transform_after_link_from_panics — exercise the record-level panic from set_producer_service / set_transform.
  • multiple_link_from_allowed — confirms fan-in is still permitted (two link_from calls, asserts inbound_connectors().len() == 2).

@lxsaah lxsaah requested a review from Copilot May 8, 2026 19:43
@lxsaah lxsaah self-assigned this May 8, 2026
@lxsaah lxsaah linked an issue May 8, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enforces configuration-time mutual exclusion between local writers (.source(), .transform()) and inbound connectors (.link_from()) so a record can’t be configured with multiple competing producers that would otherwise degrade to last-writer-wins.

Changes:

  • Added symmetric config-time panics to prevent mixing .link_from() with .source() or .transform().
  • Added builder-level pre-check in inbound connector .finish() to produce a URL-bearing panic message.
  • Added unit tests covering the new exclusivity rules and confirming multiple .link_from() calls remain allowed.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
CHANGELOG.md Notes the new writer-exclusivity validation behavior at the repo level.
aimdb-core/src/typed_record.rs Adds defense-in-depth exclusivity checks in set_producer_service, set_transform, and add_inbound_connector.
aimdb-core/src/typed_api.rs Adds builder-level exclusivity checks in inbound connector finish() and adds tests for the new behavior.
aimdb-core/CHANGELOG.md Documents the feature addition in the crate changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aimdb-core/CHANGELOG.md
@lxsaah lxsaah merged commit ba6b7dc into main May 8, 2026
9 checks passed
@lxsaah lxsaah deleted the 89-validate-writer-exclusivity-for-link_from-at-config-time branch May 8, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate writer-exclusivity for link_from at config time

2 participants